package com.mianshi;

import java.util.Scanner;

/**
 * 比较版本号
 */
public class tuya {
    public static void main(String[] args) {
        String s1 = "1.01";
        String s2 = "1.2.001";
        System.out.println(cal(s1,s2));
    }

    public static int cal(String version1, String version2){
        String[] arr1 = version1.split("\\.");
        String[] arr2 = version2.split("\\.");
        int index = 0;
        int diff = 0;
        int min = Math.min(arr1.length, arr2.length);
        if(arr1.length != arr2.length){
            return arr1.length > arr2.length ? 1 : -1;
        }
        while(index < min){
            int num1 = Integer.parseInt(arr1[index]);
            int num2 = Integer.parseInt(arr2[index]);
            diff = num1 - num2;
            if (diff != 0) {
                break;
            } else {
                index++;
            }
        }
        if(index == min) return 0;
        else {
            return  diff > 0 ? 1 : -1;
        }
    }
}

//
//if(version1 == null && version2 == null) return 0;
//        if(version1 == null) return -1;
//        if(version2 == null) return 1;
//        String[] arr1 = version1.split("\\.");
//        String[] arr2 = version2.split("\\.");
//        int index = 0;
//        int diff = 0;
//        int min = Math.min(arr1.length, arr2.length);
//        while(index < min
//                && (diff = arr1[index].length() - arr2[index].length()) == 0
//                        && (diff = arr1[index].compareTo(arr2[index])) == 0){
//                        index++;
//                        }
//                        diff = (diff != 0) ? diff : arr1.length - arr2.length;
//                        return diff;